DBtools.h++

Platforms: Windows 3.1, Windows NT, Solaris, SunOS, HP/UX, and IBM/AIX
Databases: Sybase, Oracle, Ingres, Informix, and ODBC
Source and object code

DBtools.h++ coding example

This sample program demonstrates the code to copy data from an RDBMS to a spreadsheet. The explanation follows the code.

Code

#include 

int main ()
{
   1	RWDBDatabase enterpriseDB = RWDBManager : : database
		("SYBASE", "SYBASESERVER", "ME", "PASSWORD", "DATA");

	RWDBTable table1 = enterpriseDB.table("Actual_Sales");

	RWDBReader table1Reader = table1.reader();

   2	RWDBDatabase spreadsheet = RWDBManager : : database
		("ODBC", "MS_EXCEL", "ME", "PASSWORD", "C:\\mydir");

   3	spreadsheet.createTable ("TMPSALES", table1.schema());
	RWDBTable spreadsheetTable = spreadsheet.table ("TMPSALES");

   4	RWDBInserter localInserter = spreadsheetTable.inserter();
	while (table1Reader())
	{
		localInserter << table1Reader;
		localInserter.execute();
	}
   5	...
	/* Insert DDE code to plot your sales forecast, stored
	       in the second spreadsheet, versus actual sales now
	       stored in the TMPSALES spreadsheet. */
}

Explanation

  1. Connect to the enterprise database, which contains recorded sales for the year.
  2. Connect to the second database; in this case it is a spreadsheet with an ODBC driver.
  3. Use DBtools.h++ to build and execute an SQL statement that creates a table. Via ODBC, this creates a spreadsheet named TMPSALES to temporarily store the sales records.
  4. Insert the sales records into the spreadsheet, with DBtools.h++ automatically mapping the datatypes from Database 1 to types known to Database 2. The data fills the new spreadsheet starting at cell A1. (Take a moment and think about how tedious this would be using the ODBC API together with the API associated with your RDBMS.)
  5. Now use standard spreadsheet directives to plot the data you╘ve brought from the enterprise database versus your own data stored in another spreadsheet.
Order now     DBtools.h++     More about DBtools.h++

© Copyright 1995, Rogue Wave Software, Inc.